﻿using Saisie_des_prélèvements.Models;
using System;
using System.Linq;
using System.Collections.ObjectModel;
using System.Collections.Generic;

namespace Saisie_des_prélèvements.ViewModels
{
    class IDENTViewModel : ViewModelBase
    {
        #region Properties
        private string ID_VALEUR { get; set; }
        public string DisplayValue
        {
            get
            { return ID_VALEUR; }

            set
            {
                if (ID_VALEUR == value)
                { return; }

                ID_VALEUR = value;
                RaisePropertyChanged("DisplayValue");
            }
        }

        #endregion Properties

        public List<IDENTViewModel> GetIdentValue(string TableIdent)
        {
            var db = new SQLite.SQLiteConnection(App.DBPath);
            string Query = string.Empty;
            if (TableIdent.Contains("IDENT"))
                Query = string.Format("SELECT DISTINCT ID_VALEUR DisplayValue FROM {0}", TableIdent);
            else
                Query = string.Format("SELECT DISTINCT PP_LIBELLE DisplayValue FROM PTPREL");

            List<IDENTViewModel> result = db.Query<IDENTViewModel>(Query);
            return result;
        }
    }
}
